import { ListOption, APIBase } from '../../base/api-base';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root',
})
export class WhitelistDetailService implements Resolve<any> {
  constructor(private http: HttpClient) {}

  async resolve(route: ActivatedRouteSnapshot) {
    const id = Number(route.queryParamMap.get('id'));
    return await this.http.get<WhiteList>(`/api/admin/usb/whitelist/${id}`).toPromise();
  }

}

export interface WhiteList {
  id?: number,
  alias_name?: string,
  remarks?: string,
  vendor_id?: string,
  product_id?: string,
  serial_number?: string,
  expiry_date?: string,
  created_at?: string,
  updated_at?: string,
  authorization?: number
  remaining_date?: string
}

export interface WhitelistOptions extends ListOption {
  id?: number;
  auth_type?: number;
  keywords?: string;
  area_id?: number;
  is_authorized?: number;
}